/*            Copyright(c) 2006-2008 Dave Sexton           *
 * http://www.codeplex.com/DocProject                      *
 * http://www.codeplex.com/DocProject/Project/License.aspx *
 ***********************************************************/
using System;
using System.Collections.Generic;
using System.Text;
using System.Collections.ObjectModel;

namespace DaveSexton.DocProject.Sandcastle
{
	public sealed class SourceVersionCollection : Collection<SourceVersion>
	{
		#region Public Properties
		#endregion

		#region Private / Protected
		#endregion

		#region Constructors
		/// <summary>
		/// Constructs a new instance of the <see cref="SourceVersionCollection" /> class.
		/// </summary>
		public SourceVersionCollection()
		{
		}

		/// <summary>
		/// Constructs a new instance of the <see cref="SourceVersionCollection" /> class.
		/// </summary>
		public SourceVersionCollection(IList<SourceVersion> versions)
			: base(versions)
		{
		}

		/// <summary>
		/// Constructs a new instance of the <see cref="SourceVersionCollection" /> class.
		/// </summary>
		public SourceVersionCollection(IEnumerable<SourceVersion> versions)
			: base(new List<SourceVersion>(versions))
		{
		}
		#endregion

		#region Methods
		protected override void InsertItem(int index, SourceVersion item)
		{
			if (item == null)
				throw new ArgumentNullException("item");

			if (!this.Contains(item))
				base.InsertItem(index, item);
		}

		protected override void SetItem(int index, SourceVersion item)
		{
			if (item == null)
				throw new ArgumentNullException("item");

			if (!this.Contains(item))
				base.SetItem(index, item);
		}

		public void AddRange(IEnumerable<SourceVersion> versions)
		{
			foreach (SourceVersion version in versions)
				Add(version);
		}
		#endregion
	}
}
